package org.dbwebx.flex.control
{

	import mx.controls.Label;
	import mx.formatters.DateFormatter;

	public class DateLabel extends Label
	{

		public function DateLabel()
		{
			super();
			_dateFormatter=new DateFormatter();
			_dateFormatter.formatString=_dateFormat;
		}

		/**
		 * The date format.
		 * @default M/D/Y J:NN:SS
		 */
		private var _dateFormat:String="M/D/Y J:NN:SS";

		/**
		 * The <code>DateFormatter</code> instance reference.
		 * @default
		 */
		private var _dateFormatter:DateFormatter;

		override public function set data(value:Object):void
		{
			var dateLabel:Object=value;
			if (dateLabel)
			{
				dateLabel=_dateFormatter.format(dateLabel);
			}
			super.data=dateLabel;
		}

		public function get dateFormat():String
		{
			return _dateFormat;
		}

		public function set dateFormat(value:String):void
		{
			if (value)
			{
				_dateFormat=value;
				_dateFormatter.formatString=value;
			}
		}

	}
}